class Solution {
public:
    int romanToInt(string s) {
        unordered_map<char, int> map1 = { {'I',1},{'V',5},{'X',10},{'L',50},{'C',100},{'D',500},{'M',1000} };
        int count = 0;
        for (int i = 0; i < s.size(); i++)
        {
            if (s[i] == 'I' && s[i + 1] == 'V')
            {
                count += 4;
                i += 1;
                continue;

            }
            if (s[i] == 'I' && s[i + 1] == 'X')
            {
                count += 9;
                i += 1;
                continue;

            }
            if (s[i] == 'X' && s[i + 1] == 'L')
            {
                count += 40;
                i += 1;
                continue;

            }
            if (s[i] == 'X' && s[i + 1] == 'C')
            {
                count += 90;
                i += 1;
                continue;

            }
            if (s[i] == 'C' && s[i + 1] == 'D')
            {
                count += 400;
                i += 1;
                continue;

            }
            if (s[i] == 'C' && s[i + 1] == 'M')
            {
                count += 900;
                i += 1;
                continue;
            }
            count += map1[s[i]];
        }
        return count;
    }
};